<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class='app-container'>
    <el-row>
      <el-col :span='22' :xs='24'>
        <el-form ref="form" :model="quo" :rules="rules" label-width="100px" id="mvcfm">
          <el-button @click="gotoPage('/crm/sale/OfferUp?'+vueparams+'')" type='success' size="mini"><i class='fa fa-edit'></i>修改</el-button>
          <el-button @click="gotoPage('/crm/sale/Offer?'+vueparams+'')" type='primary' size="mini"><i class='fa fa-reply'></i>返回</el-button>
          <el-button @click="gotoPage('/crm/sale/PrintInfo?'+vueparams+'')" type='primary' size="mini">打印</el-button>
          <div class="form-unit">
            <span class="mvc-title-left"> 报价明细 </span>
          </div>
          <div>
            <el-row>
              <el-col :span="24">
                <el-form-item label="报价条形码" prop="">
                  {{quo.quo_barcode}}
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="主题" prop="">
                  {{quo.quo_theme}}
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="客户" prop="">
                  {{quo.quo_client}}
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="客户等级" prop="">
                  {{quo.crate}}
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="联系人" prop="">
                  {{quo.quo_contact}}
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="内部备注" prop="">
                  <div style="white-space: pre-wrap;">{{quo.quo_insides}}</div>
                </el-form-item>
              </el-col>
            </el-row>
          </div>
          <div class="form-unit">
            <span class="mvc-title-left"> 列表条目 </span>
          </div>
          <el-table :data="pum">
            <el-table-column label="操作" align="center" width='100' type=''>
              <template slot-scope="scope">
                <el-dropdown trigger="click">
                  <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item>
                      <el-link @click="d_producenum('&pronum_id='+scope.row.pronum_id+'')">删除</el-link>
                    </el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>
              </template>
            </el-table-column>
            <el-table-column label="产品条形码" prop="product_barcode">
            </el-table-column>
            <el-table-column label="产品名称" prop="pronum_prodece">
            </el-table-column>
            <el-table-column label="产品型号" prop="product_model">
            </el-table-column>
            <el-table-column label="产品规格" prop="product_norm">
            </el-table-column>
            <el-table-column label="生产厂家" prop="dname">
            </el-table-column>
            <el-table-column label="生产厂家" prop="cname">
            </el-table-column>
            <el-table-column label="交换地点" prop="paddress">
            </el-table-column>
            <el-table-column label="预计时间" prop="pronum_endate">
            </el-table-column>
            <el-table-column label="数量" prop="pronum_no">
            </el-table-column>
            <el-table-column label="单价" prop="pronum_price">
            </el-table-column>
            <el-table-column label="总价" prop="total_prices">
            </el-table-column>
          </el-table>
          <div>
            <el-row>
              <el-col :span="24">
                <el-form-item label="合计" prop="">
                  {{s_num.total_prices}}
                </el-form-item>
              </el-col>
            </el-row>
          </div>
          <el-button @click="popEntryChoiceList('&category_id=')" type='primary' size="mini">选择产品</el-button>
          <div class="form-unit">
            <span class="mvc-title-left"> 付款条件 </span>
          </div>
          <el-table :data="s_condition">
            <el-table-column label="操作" align="center" width='100' type=''>
              <template slot-scope="scope">
                <el-dropdown trigger="click">
                  <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item>
                      <el-link @click="popEntryChoiceUp('&CMID2='+scope.row.condition_id+'')">修改</el-link>
                    </el-dropdown-item>
                    <el-dropdown-item>
                      <el-link @click="d_condition('&CMID2='+scope.row.condition_id+'')">删除</el-link>
                    </el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>
              </template>
            </el-table-column>
            <el-table-column label="备注" prop="condition_name">
            </el-table-column>
          </el-table>
          <el-button @click="popPaymentConditionChoice('')" type='primary' size="mini">选择付款条件</el-button>
          <div class="form-unit">
            <span class="mvc-title-left"> 报价说明 </span>
          </div>
          <el-table :data="s_explain">
            <el-table-column label="操作" align="center" width='100' type=''>
              <template slot-scope="scope">
                <el-dropdown trigger="click">
                  <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item>
                      <el-link @click="popSuppExplainUp('&CMID2='+scope.row.explain_id+'')">修改</el-link>
                    </el-dropdown-item>
                    <el-dropdown-item>
                      <el-link @click="d_explain('&CMID2='+scope.row.explain_id+'')">删除</el-link>
                    </el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>
              </template>
            </el-table-column>
            <el-table-column label="备注" prop="explain_name">
            </el-table-column>
          </el-table>
          <el-button @click="popSuppExplainChoice('')" type='primary' size="mini">选择说明</el-button>
        </el-form>
      </el-col>
      <el-col :span='2' :xs='24'>
        <el-menu default-active='active' class='menu-unit'>
          <el-menu-item v-for='item in Container'>
            <el-link @click="gotoMenu(item.url)" :type="'产品报价'===item.name?'primary':'default'">{{item.page_desc||item.name}}</el-link>
          </el-menu-item>
        </el-menu>
      </el-col>
    </el-row>
    <el-dialog :visible.sync="EntryChoiceListVisible" append-to-body>
      <EntryChoiceList v-if="EntryChoiceListVisible" ref="EntryChoiceList" :popparams="popparams"> </EntryChoiceList>
    </el-dialog>
    <el-dialog :visible.sync="EntryChoiceUpVisible" append-to-body>
      <EntryChoiceUp v-if="EntryChoiceUpVisible" ref="EntryChoiceUp" :popparams="popparams"> </EntryChoiceUp>
    </el-dialog>
    <el-dialog :visible.sync="PaymentConditionChoiceVisible" append-to-body>
      <PaymentConditionChoice v-if="PaymentConditionChoiceVisible" ref="PaymentConditionChoice" :popparams="popparams"> </PaymentConditionChoice>
    </el-dialog>
    <el-dialog :visible.sync="SuppExplainUpVisible" append-to-body>
      <SuppExplainUp v-if="SuppExplainUpVisible" ref="SuppExplainUp" :popparams="popparams"> </SuppExplainUp>
    </el-dialog>
    <el-dialog :visible.sync="SuppExplainChoiceVisible" append-to-body>
      <SuppExplainChoice v-if="SuppExplainChoiceVisible" ref="SuppExplainChoice" :popparams="popparams"> </SuppExplainChoice>
    </el-dialog>
  </div>
</template>
<script>
  import request from '@/utils/request'
  import EntryChoiceList from "@/views/crm/sale/EntryChoiceList";
  import EntryChoiceUp from "@/views/crm/sale/EntryChoiceUp";
  import PaymentConditionChoice from "@/views/crm/sale/PaymentConditionChoice";
  import SuppExplainUp from "@/views/crm/sale/SuppExplainUp";
  import SuppExplainChoice from "@/views/crm/sale/SuppExplainChoice";
  export default {
    name: 'OfferDetMes',
    components: {
      EntryChoiceList,
      EntryChoiceUp,
      PaymentConditionChoice,
      SuppExplainUp,
      SuppExplainChoice,
    },
    props: ['popparams'],
    data() {
      return {
        EntryChoiceListVisible: false,
        EntryChoiceListValue: null,
        EntryChoiceListDesc: null,
        EntryChoiceUpVisible: false,
        EntryChoiceUpValue: null,
        EntryChoiceUpDesc: null,
        PaymentConditionChoiceVisible: false,
        PaymentConditionChoiceValue: null,
        PaymentConditionChoiceDesc: null,
        SuppExplainUpVisible: false,
        SuppExplainUpValue: null,
        SuppExplainUpDesc: null,
        SuppExplainChoiceVisible: false,
        SuppExplainChoiceValue: null,
        SuppExplainChoiceDesc: null,
        vueparams: this.getVUEParams(""),
        quo: {
          quo_barcode: null,
          quo_theme: null,
          quo_client: null,
          crate: null,
          quo_contact: null,
          quo_insides: null,
        },
        pum: [],
        s_num: {
          total_prices: null,
        },
        s_condition: [],
        s_explain: [],
        loading: false,
        Container: null,
        rules: {}
      }
    },
    created() {
      this.getData();
      this.loadContainerMenu({
        pid: "80299289AF2443B18EA545A4C0C37170",
        name: "客户管理右菜单",
        selected: "产品报价"
      }, 'Container', this.vueparams);
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/crm/sale/OfferDetMes/offerDetMes?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      d_producenum(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/crm/sale/OfferDetMes/d_producenum?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      d_condition(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/crm/sale/OfferDetMes/d_condition?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      d_explain(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/crm/sale/OfferDetMes/d_explain?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      popEntryChoiceList(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.EntryChoiceListVisible = !this.EntryChoiceListVisible;
      },
      popEntryChoiceUp(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.EntryChoiceUpVisible = !this.EntryChoiceUpVisible;
      },
      popPaymentConditionChoice(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.PaymentConditionChoiceVisible = !this.PaymentConditionChoiceVisible;
      },
      popSuppExplainUp(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.SuppExplainUpVisible = !this.SuppExplainUpVisible;
      },
      popSuppExplainChoice(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.SuppExplainChoiceVisible = !this.SuppExplainChoiceVisible;
      },
    },
  }
</script>
